<?php

/**
 * @Author:  Groube
 * @Date:    2017-03-06 16:00:00
 * @version  $Id$
 */

class ZhuyuanFuzhuJianchaModel extends BaseModel {

    //返回给终端的可执行sql语句的字段名称数组
    public $_field_arr = [
                            'id',
                            'zhuyuan_id',
                            'jiancha_mingcheng',
                            'songjianwu',
                            'jiancha_keshi',
                            'jiancha_zhuangtai',
                            'tiaoma',
                            'hedui_hushi_mingcheng',
                            'hedui_hushi_id',
                            'hedui_time',
                            'shenqing_time'
                         ];

    public $_biaoben_field_arr = [
                            'id',
                            'zhuyuan_id',
                            'jiancha_mingcheng',
                            'songjianwu',
                            'jiancha_keshi',
                            'jiancha_zhuangtai',
                            'tiaoma',
                            'hedui_hushi_mingcheng',
                            'hedui_hushi_id',
                            'hedui_time',
                            'shenqing_time',
                            'modify_time'
                         ];

    public function ls($zhuyuan_fuzhujiancha,$zhuayun_bingren,$yiyuan_id){
        $field_str = 'id,zhuyuan_id,jiancha_mingcheng,songjian_wu as songjianwu,jiancha_keshi_name as jiancha_keshi,jiancha_hedui_zhuangtai as jiancha_zhuangtai,biaoben_tiaoma as tiaoma,jiancha_hedui_hushi_name as hedui_hushi_mingcheng,jiancha_hedui_hushi_id as hedui_hushi_id,jiancha_hedui_time as hedui_time,shenqing_time';
        $query = DB::select($field_str)->from($zhuyuan_fuzhujiancha)
            ->where('zhuyuan_id','IN',$zhuayun_bingren)
            ->where('yiyuan_id','=',$yiyuan_id)
            ->where('biaoben_tiaoma','IS NOT',NULL)
            ->execute()->as_array();

        return $query;
    }

    public function ls_biaoben($zhuayun_bingren,$yiyuan_id,$upload_data,$modify_time=''){
    	$field_str = 'id,zhuyuan_id,jiancha_mingcheng,songjian_wu as songjianwu,jiancha_keshi_name as jiancha_keshi,jiancha_hedui_zhuangtai as jiancha_zhuangtai,biaoben_tiaoma as tiaoma,jiancha_hedui_hushi_name as hedui_hushi_mingcheng,jiancha_hedui_hushi_id as hedui_hushi_id,jiancha_hedui_time as hedui_time,shenqing_time';
        $zhuyuan_fuzhujiancha_query = DB::select($field_str)->from('zhuyuan_fuzhujiancha')
            ->where('zhuyuan_id','IN',$zhuayun_bingren)
            ->where('yiyuan_id','=',$yiyuan_id);

        if(!empty($upload_data)){
            $zhuyuan_fuzhujiancha_query->where('biaoben_tiaoma','NOT IN',$upload_data);
        }

        if($modify_time){
            $zhuyuan_fuzhujiancha_query->where('modify_time','>=',$modify_time);
        }
        $zhuyuan_fuzhujiancha_query->where('biaoben_tiaoma','IS NOT',NULL)
        	->and_where('jiancha_hedui_zhuangtai', 'in', ['未核对','已核对']);
        $zhuyuan_fuzhujiancha_list = $zhuyuan_fuzhujiancha_query->execute()->as_array();
        return $zhuyuan_fuzhujiancha_list;
    }
}
